//
//  ExamLevel.swift
//  Exam-iOS
//
//  Created by 李胜锋 on 2018/2/28.
//  Copyright © 2018年 李胜锋. All rights reserved.
//

import Foundation


class ExamLevel {
    ///考试级别列表
    static func levelList(success: NetworkSuccess?,
                          failure: NetworkFailure?) {
        let path = "level/list"
        
//        var para = [String: Any]()
//        if let levelId = AccountStorage.default.levelId {
//            para["levelId"] = levelId
//        }
//
        NetworkService.get(path, success: success, failure: failure)
    }
    
    ///设置考试级别
    static func levelSelect(levelId: Int,
                            success: NetworkSuccess?,
                            failure: NetworkFailure?) {
        let path = "level/user-selected"
        let para = ["levelId": levelId]
        NetworkService.post(path, parameter: para, success: { (response, data) in
            
            NotificationCenter.default.post(name: Notification.Name(rawValue: AccountLevelIdChangedNotification), object: levelId)
            AccountStorage.default.account.levelId = levelId
            AccountStorage.default.updateAccount()
            success?(response, data)
        }, failure: failure)
    }
}
